#!/usr/bin/env bash
set -x

date

df

kubectl get pods --all-namespaces -o wide | grep Evicted | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n
kubectl get pods --all-namespaces -o wide | grep Error | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n
kubectl get pods --all-namespaces -o wide | grep Completed | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n
kubectl describe -A pvc | grep -E "^Name:.*$|^Namespace:.*$|^Used By:.*$" | grep -B 2 "<none>" | grep -E "^Name:.*$|^Namespace:.*$" | cut -f2 -d: | paste -d " " - - | xargs -n2 bash -c 'kubectl -n ${1} delete pvc ${0}'
kubectl get pvc --all-namespaces | tail -n +2 | grep -v Bound | awk '{print $1,$2}' | xargs -L1 kubectl delete pvc -n
#kubectl get pv | tail -n +2 | grep -v Bound | awk '{print $1}' | xargs -L1 kubectl delete pv
ps -A -ostat,ppid | grep -e '^[Zz]' | awk '{print }' | xargs kill -HUP
docker ps -a | grep Exited | awk '{print "docker rm "$1";docker rmi "$2";"}' | bash -s -
docker images | awk '{print "docker ps|grep -E \"("$3"|"$1")\"||docker rmi "$3}' | bash -s -
docker images | grep none | awk '{print $3}' | xargs docker rmi
docker volume rm "$(docker volume ls -q)"
#docker volume prune
docker builder prune -f
docker system prune -f

df
